package model;

import java.awt.Color;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Food implements Drawable {

	/** Hold locations of the food. */
	//private Point[] foodLocations;
	private List<Point> foodLocations;
	
	/** What color is the food? */
	private Color color;
	
	/** The number of squares to divide the board into.*/
	private int numSquares = 10;

	/** The number of bits of food */
	private int totalItems = 10;
	
	/** The size of a piece of food */
	private int foodSize = 10;

	public Food(int foodCount, int numSquares, int foodSize) {
		this. totalItems = foodCount;
		this.numSquares = numSquares;
		this.foodSize = foodSize;
		calculateFood();
	}
	
	/** Setup the locations of the food */
	private void calculateFood() {
		Random random = new Random(numSquares);
		foodLocations = new ArrayList<Point>(totalItems);
		for (int i = 0; i < totalItems; i++) {
			foodLocations.add(new Point(random.nextInt(numSquares) * foodSize, 
					random.nextInt(numSquares) * foodSize));
		}
	}
	
	/** {@inheritDoc} */
	public Point[] getLocations() {
		return foodLocations.toArray(new Point[]{});
	}
	
	public void remove(Point point) {
		foodLocations.remove(point);
	}
	
	@Override
	public String toString() {
		return "Food [color=" + color + ", foodLocations="
				+ foodLocations + ", numSquares=" + numSquares
				+ ", totalItems=" + totalItems + "]";
	}

	/** {@inheritDoc} */
	public Color getColor() {
		return Color.RED;
	}
	
	public static void main(String[] args) {
		Food glorious = new Food(10, 10, 10);
		System.out.println(glorious);
	}

}
